'use strict';

import { DataTypes } from 'sequelize'
import sequelize from '../utils/database.js'
import BaseModel from './BaseModel.js'

class SystemMenu extends BaseModel {
  /**
   * Helper method for defining associations.
   * This method is not a part of Sequelize lifecycle.
   * The `models/index` file will call this method automatically.
   */
  static associate(models) {
    // define association here
  }
}
SystemMenu.init({
  system_permission_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '关联权限id，菜单是对应权限的'
  },
  parent_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0,
    comment: '父级id'
  },
  name: {
    type: DataTypes.STRING(45),
    allowNull: false,
    defaultValue: '',
    comment: '菜单名称'
  },
  icon: {
    type: DataTypes.STRING(45),
    allowNull: false,
    defaultValue: '',
    comment: '展示icon'
  },
  path: {
    type: DataTypes.STRING(45),
    allowNull: false,
    defaultValue: '',
    comment: '访问路由'
  },
  view: {
    type: DataTypes.STRING(100),
    allowNull: false,
    defaultValue: '',
    comment: '文件路径'
  },
  sort: {
    type: DataTypes.TINYINT,
    allowNull: false,
    defaultValue: 0,
    comment: '排序'
  },
  additional: {
    type: DataTypes.STRING,
    allowNull: false,
    defaultValue: '',
    comment: '附加字段'
  },
  description: {
    type: DataTypes.STRING,
    allowNull: false,
    defaultValue: '',
    comment: '菜单描述'
  },
  status: {
    type: DataTypes.TINYINT,
    allowNull: false,
    defaultValue: 1,
    comment: '1:显示，2：隐藏'
  },
}, {
  sequelize,
  modelName: 'SystemMenu',
  tableName: 'system_menu'
});

export default SystemMenu
